package com.cloud.demo.login.controller;

import com.cloud.demo.common.result.BaseResult;
import com.cloud.demo.login.bean.dto.LoginByAccountDTO;
import com.cloud.demo.login.bean.vo.TokenVo;
import com.cloud.demo.login.service.LoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 类说明
 *
 * @author szj
 * @date 2021/7/20
 */
@Slf4j
@RestController
@RequestMapping("/login")
@Api(value = "LoginController")
public class LoginController {
    @Resource
    private LoginService loginService;

    @RequestMapping(value = "loginByAccount", method = RequestMethod.POST)
    @ApiOperation("通过账号密码登录")
    @ApiImplicitParams({@ApiImplicitParam(name = "loginByAccountDTO", value = "卡片ID", required = true, dataType = "LoginByAccountDTO")})
    public BaseResult<TokenVo> loginByAccount(@RequestBody LoginByAccountDTO loginByAccountDTO) {
        return loginService.loginByAccount(loginByAccountDTO);
    }
}
